set more off

*** read data ***

use "reassessments", clear
merge m:m swis_code year using "switchers"
drop _m
merge m:m muni_name county_name year using "census demographics"
drop _m
drop if mi(swis_code)
keep if year > 1986 & year < 2012

*** recode for interpretation ***

gen elected = 1-D
replace reass = reass * 100

gen salience = pct65plus1990
su salience
gen electedXsalience = elected*salience

*** do the graphs ***

gen B = .
gen SE = .


xtile qsalience = salience, nq(5)
tabulate qsalience, gen(qsalience_)
forvalues i = 1(1)5 {
	gen qsalience`i'Xelected = qsalience_`i'*elected
}
#delimit;
xi: areg reass 
	elected
	qsalience_2 qsalience_3 qsalience_4 qsalience_5
	qsalience2Xelected qsalience3Xelected qsalience4Xelected qsalience5Xelected
	i.year, a(swis_code) cl(swis_code)
	;
#delimit cr

mat V = e(V)

replace B = _b[elected] if qsalience == 1
replace SE = _se[elected] if qsalience == 1
forvalues i = 2(1)5 {
	replace B = _b[elected] + _b[qsalience`i'Xelected] if qsalience == `i'
	replace SE = sqrt(V[1,1] + V[`i'+4,`i'+4] + 2*V[`i'+4,1]) if qsalience == `i'
	
}


collapse B SE salience, by(qsalience)
gen UB = B + 1.96*SE
gen LB = B - 1.96*SE

#delimit;

gr tw 
	(sc B qsalience, col(black) msize(vlarge))
	(rcap UB LB qsalience, col(black))
	(lfit B qsalience, col(black) lpat(dash))
	,
		yline(0)
		legend(off)
		plotregion(style(none))
		ytitle("Effect of elected assessor")
		xtitle("Percent 65 plus (quintile)")	
		ylab(, angle(horiz))
		;

#delimit cr


gr export "figure A5.eps", replace


